<template>
  <div>
    <el-dialog title="查看文件" :visible="dialogPlanView" width="35%">
      <el-form
        :model="formData"
        ref="formData"
        v-for="(item, i) in formData"
        :key="i"
        class="formData"
      >
        <el-form-item label="完成照片" label-width="80px" prop="img">
            <el-image :src="aa(item.img)"> </el-image>
        </el-form-item>

        <el-form-item label="客户是否跟随" prop="companionFlag" label-width="85px">
          <el-radio-group v-model="item.companionFlag">
            <el-radio label="1">是</el-radio>
            <el-radio label="2">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="巡检时间" prop="checkTime" label-width="80px">
          <el-date-picker
            v-model="item.checkTime"
            type="date"
            placeholder="选择日期"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注信息" label-width="80px" prop="item.remark">
          <el-input type="textarea" :rows="2" v-model="item.remark" disabled> </el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="resetForm()">取 消</el-button>
        <el-button type="primary" @click="submitForm()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { uploadFile } from "../../../api/upload";
import { selectCheck } from "../../../api/basisProgressNode.js";
// import COS from 'cos-js-sdk-v5'
// const cos = new COS({
//   SecretId: 'AKID8G7h15sOcaGfohKglZBWaNt86mDOIvHN', // 身份识别ID
//   SecretKey: 'qa3GCrEK9k47uQgfNp0uY0EBrHQIuGRO' // 身份秘钥
// })

export default {
  props: {
    dialogPlanView: {
      type: Boolean,
      default: false,
    },
    nodeCode: {
      type: String,
    },
    orderId: {
      type: String,
    },
    initData: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      src: "",
      formData: {
        remark: null,
        nodeCode: null,
        orderId: null,
        img: null,
        checkTime: null,
        companionFlag: null,
        http:"http://localhost:8000"
      },
    };
  },
  methods: {
    aa(img){
        return this.http + img;
    },
    submitForm() {
      this.$emit("update:dialogPlanView", false);
    },
    resetForm() {
      this.$emit("update:dialogPlanView", false);
    },
    async queryForm() {
      try {
        const res = await selectCheck(this.nodeCode, this.orderId);
        // console.log(res);
        this.formData = res.data.data;
        console.log(this.formData);
      } catch (error) {
        this.$message.error("查询失败");
      }
    },
  },
  async created() {
    await this.queryForm();
  },
};
</script>
<style lang="less">
.formdata {
  border: #3d6df8 solid 1px;
}
</style>
